<?php
namespace Home\Controller;
use Think\Controller;
class AmentController extends Controller {
    public function showAm(){
    $this->display();
    }

        public function getAm(){
            $cate=M('category');
            $data=$cate->select();
            $this->ajaxReturn($data);
        }
    public function getGoods(){
        $goods=M('goods');
        $data=$goods->select();
        $this->ajaxReturn($data);

    }
    public function addAm(){
        $goods = M("goods");

        $id=$_POST["id"];

        //print_r($_POST);


        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize   =     3145728 ;// 设置附件上传大小
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->rootPath  =      './Uploads/'; // 设置附件上传根目录
        $upload->savePath =  '';


        $info   =   $upload->uploadOne($_FILES['goods_img']);
        if(!$info) {// 上传错误提示错误信息

        }else{
            $img='./uploads/'.$info['savepath'].$info['savename'];

            $goods-> where("id=$id")->setField('goods_img',$img);
        }












        $goods-> where("id=$id")->data($_POST)->save();
        echo "<h1>修改成功</h1> <a href='/Jd/index.php/Home/ShowList/show#'>返回商品列表</a>";

    }
}